package com.test.lotterysystem.Dao.Mapper;


import com.test.lotterysystem.Dao.DaoObject.UserDO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface UserMapper {

    @Select("select count(*) from user where email = #{mail}")
    Integer mailIsUse(String mail);

    @Select("select count(*) from user where phone_number = #{phoneNumber}")
    Integer phoneIsUse(String phoneNumber);

    @Insert("insert into user (user_name, email, phone_number, password, identity) " +
            "values (#{userName},#{email},#{phoneNumber,typeHandler=com.test.lotterysystem.Dao.TypeHandler.EncryptTypeHandler},#{password},#{identity})")
    @Options(useGeneratedKeys = true,keyProperty = "id",keyColumn = "id")
    void insert(UserDO userDO);


}
